home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / uip / snd / s_arginit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-03-12  |  3.0 KB  |  110 lines

  1. /*
  2. **        S _ A R G I N I T
  3. **
  4. **  This function parses and uses the information found on the command
  5. **  line.
  6. **
  7. **
  8. **    R E V I S I O N  H I S T O R Y
  9. **
  10. **    03/31/83  GWH    Split the SEND program into component parts
  11. **
  12. */
  13.  
  14. #include "./s.h"
  15. #include "./s_externs.h"
  16.  
  17. char *UsageMessage = 
  18. "Usage:  snd addrs -a hdr:val -{bct} addrs -f file -h host -s subj -n\n";
  19.  
  20. arginit (argc, argv)              /* parse and use the argument list    */
  21. int     argc;
  22. char   *argv[];
  23. {
  24.     char *curfld;
  25.     char *cp;
  26.     register short curarg;
  27.  
  28. /*  strcpy (host, locname); */  /* setup default host reference */
  29. #ifdef JNTMAIL
  30.     sprintf(host, "%s.%s",ap_dmflip(locdomain),locname );
  31. #else
  32.     sprintf(host, "%s.%s", locname, locdomain );
  33. #endif
  34.  
  35. /*  if an argument is not a switch, assume that it is an address.
  36.  *  several of the switches merely change which header addresses are
  37.  *  to be added to.  after an argument is processed, the pointer to
  38.  *  it is nulled, so that it will no longer be visible by a system-
  39.  *  status command ("ss" on the UDel machine).
  40.  */
  41.  
  42.     for (curfld = to, curarg = 1; curarg < argc; )
  43.     {                             /* regular scan of arg list           */
  44.                   /* default to adding to To field      */
  45.     if (argv[curarg][0] != '-')
  46.         aliasmap(curfld, argv[curarg], host);
  47.                   /* add it to current field            */
  48.     else {                    /* a switch                           */ 
  49.         switch (argv[curarg][1])
  50.         {
  51.             case 'a':
  52.                 if (++curarg >= argc)
  53.                 break;
  54.                 if (cp = index(argv[curarg], ':'))
  55.                 *cp++ = '\0';
  56.             addheader(argv[curarg], cp);
  57.             break;
  58.  
  59.         case 'b':         /* add to end of bcc field            */
  60.             curfld = bcc;
  61.             break;
  62.  
  63.             case 'd':      /* grandfather the direct edit option */
  64.                 break;      /* NOOP */
  65.                 
  66.         case 'c':         /* add to end of cc field             */
  67.             ccflag = FALSE;
  68.             curfld = cc;
  69.             break;
  70.  
  71.         case 'f':         /* add file to end of message body    */
  72.                 if (++curarg >= argc)
  73.                 break;
  74.             strcpy (inclfile, argv[curarg]);
  75.             break;        /* file is named in next argument     */
  76.  
  77.         case 'h':         /* default hostname for addresses     */
  78.                 if (++curarg >= argc)
  79.                 break;
  80.             strcpy (host, argv[curarg]);
  81.             break;        /* host is named in next argument     */
  82.  
  83.         case 'n':      /* send compatibility */
  84.             break;
  85.  
  86.         case 's':         /* add to end of Subject field        */
  87.             subjflag = FALSE;
  88.                 if (++curarg >= argc)
  89.                 break;
  90.             strncat (subject, argv[curarg],
  91.                 (S_BSIZE - strlen(subject) - 2));
  92.             break;        /* Subject is contained in next arg   */
  93.  
  94.         case 't':         /* add to end of To field             */
  95.             toflag = FALSE;
  96.             curfld = to;
  97.             break;
  98.  
  99.         default:
  100.             snd_abort ("unknown flag in '%s'\n%s", argv[curarg],
  101.                 UsageMessage);
  102.         }
  103.     }
  104.     if (argv[curarg])
  105.         argv[curarg++][0] = '\0';
  106.     }
  107.     if (to[0] != '\0')            /* at least one To was specified      */
  108.     toflag = FALSE;           /* so don't prompt for it             */
  109. }
  110.